package com.molichuxing.services.infrastructure.convertor;

import com.molichuxing.services.business.dto.request.create.OrderEnterpriseDeliveryCreateBizDto;
import com.molichuxing.services.business.dto.request.create.OrderEnterpriseReturnCreateBizDto;
import com.molichuxing.services.business.dto.response.GoodsSalesStatisticsBizDto;
import com.molichuxing.services.infrastructure.bean.*;
import com.molichuxing.services.infrastructure.dto.request.create.*;
import com.molichuxing.services.infrastructure.dto.request.modify.*;
import com.molichuxing.services.infrastructure.dto.response.*;
import com.molichuxing.services.property.*;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

public class Convert {

    public static List<OrderDto> toOrderBeanDto(List<OrderBean> beanList) {
        List<OrderDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderBean bean : beanList) {
                beanDtoList.add(toOrderBeanDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderDto toOrderBeanDto(OrderBean bean) {
        OrderDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    public static List<OrderDealerDetailStatusDto> toOrderDealerDetailStatusDto(List<OrderStatusFlowBean> beanList) {
        List<OrderDealerDetailStatusDto> orderDealerDetailStatusDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            orderDealerDetailStatusDtoList = new ArrayList<>();
            for (OrderStatusFlowBean bean : beanList) {
                orderDealerDetailStatusDtoList.add(toOrderDealerDetailStatusDto(bean));
            }
        }

        return orderDealerDetailStatusDtoList;
    }

    public static OrderDealerDetailStatusDto toOrderDealerDetailStatusDto(OrderStatusFlowBean bean) {
        OrderDealerDetailStatusDto orderDealerDetailStatusDto = null;
        if (bean != null) {
            orderDealerDetailStatusDto = new OrderDealerDetailStatusDto();
            orderDealerDetailStatusDto.setOrderStatus(bean.getOrderStatus());
            orderDealerDetailStatusDto.setGmtCreate(bean.getGmtCreate());
        }

        return orderDealerDetailStatusDto;
    }

    public static OrderDealerDetailBasicDto toOrderDealerDetailBasicDTO(OrderDealerBean bean) {
        OrderDealerDetailBasicDto beanDto = null;
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        if (bean != null) {
            beanDto = new OrderDealerDetailBasicDto();
            BeanUtils.copyProperties(bean, beanDto);
            //起租+租期=有效期
            beanDto.setPeriodValidity(dtf.format(bean.getStartLeaseDate()) + " 至 " + dtf.format(bean.getStartLeaseDate().plusMonths(bean.getTenancy()).minusDays(1)));
        }
        return beanDto;
    }


    public static List<OrderDealerDto> toOrderDealerDto(List<OrderDealerBean> beanList) {
        List<OrderDealerDto> dtoList = null;
        ;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (OrderDealerBean bean : beanList) {
                dtoList.add(toOrderDealerDto(bean));
            }
        }

        return dtoList;
    }

    public static OrderDealerDto toOrderDealerDto(OrderDealerBean bean) {
        OrderDealerDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderDealerDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static List<OrderDealerDetailCarInfoDto> toOrderDealerDetailCarInfoDto(List<OrderDealerDeliveryBean> beanList) {
        List<OrderDealerDetailCarInfoDto> orderDealerDetailCarInfoDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            orderDealerDetailCarInfoDtoList = new ArrayList<>();
            for (OrderDealerDeliveryBean bean : beanList) {
                orderDealerDetailCarInfoDtoList.add(toOrderDealerDetailCarInfoDto(bean));
            }
        }
        return orderDealerDetailCarInfoDtoList;
    }

    public static OrderDealerDetailCarInfoDto toOrderDealerDetailCarInfoDto(OrderDealerDeliveryBean bean) {
        OrderDealerDetailCarInfoDto orderDealerDetailCarInfoDto = null;
        if (bean != null) {
            orderDealerDetailCarInfoDto = new OrderDealerDetailCarInfoDto();
            BeanUtils.copyProperties(bean, orderDealerDetailCarInfoDto);
        }
        return orderDealerDetailCarInfoDto;
    }

    public static List<OrderDealerDetailStartDto> toOrderDealerDetailStartDto(List<OrderDealerDeliveryBean> beanList) {
        List<OrderDealerDetailStartDto> orderDealerDetailStartDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            orderDealerDetailStartDtoList = new ArrayList<>();
            for (OrderDealerDeliveryBean bean : beanList) {
                orderDealerDetailStartDtoList.add(toOrderDealerDetailStartDto(bean));
            }
        }
        return orderDealerDetailStartDtoList;
    }

    private static OrderDealerDetailStartDto toOrderDealerDetailStartDto(OrderDealerDeliveryBean bean) {
        OrderDealerDetailStartDto orderDealerDetailStartDto = null;
        if (bean != null) {
            orderDealerDetailStartDto = new OrderDealerDetailStartDto();
            BeanUtils.copyProperties(bean, orderDealerDetailStartDto);
            orderDealerDetailStartDto.setSendStatus(OrderDealerSendCarStatusEnum.getName(bean.getSendStatus()));
        }
        return orderDealerDetailStartDto;
    }


    public static List<OrderSubscribeDto> toOrderSubscribeBeanDto(List<OrderSubscribeBean> beanList) {
        List<OrderSubscribeDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderSubscribeBean bean : beanList) {
                beanDtoList.add(toOrderSubscribeBeanDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderSubscribeDto toOrderSubscribeBeanDto(OrderSubscribeBean bean) {
        OrderSubscribeDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderSubscribeDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setOrderStatus(bean.getOrderStatus());
        }

        return beanDto;
    }

    public static List<OrderExclusivelDto> toOrderExclusivelBeanDto(List<OrderExclusivelBean> beanList) {
        List<OrderExclusivelDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderExclusivelBean bean : beanList) {
                beanDtoList.add(toOrderExclusivelBeanDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderExclusivelDto toOrderExclusivelBeanDto(OrderExclusivelBean bean) {
        OrderExclusivelDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderExclusivelDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setOrderStatus(bean.getOrderStatus());
        }

        return beanDto;
    }

    public static List<OrderScheduleDto> toOrderScheduleBeanDto(List<OrderScheduleBean> beanList) {
        List<OrderScheduleDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderScheduleBean bean : beanList) {
                beanDtoList.add(toOrderScheduleBeanDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderScheduleDto toOrderScheduleBeanDto(OrderScheduleBean bean) {
        OrderScheduleDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderScheduleDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setPayWay(bean.getPayWay());
        }

        return beanDto;
    }

    public static List<OrderScheduleCurrentPeriodDto> toOrderScheduleCurrentPeriodBeanDto(
            List<OrderScheduleBean> beanList) {
        List<OrderScheduleCurrentPeriodDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderScheduleBean bean : beanList) {
                beanDtoList.add(toOrderScheduleCurrentPeriodBeanDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderScheduleCurrentPeriodDto toOrderScheduleCurrentPeriodBeanDto(OrderScheduleBean bean) {
        OrderScheduleCurrentPeriodDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderScheduleCurrentPeriodDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setPayWay(bean.getPayWay());
        }

        return beanDto;
    }

    public static List<OrderScheduleOverdueDto> toOrderScheduleOverdueBeanDto(List<OrderScheduleBean> beanList) {
        List<OrderScheduleOverdueDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderScheduleBean bean : beanList) {
                beanDtoList.add(toOrderScheduleOverdueBeanDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderScheduleOverdueDto toOrderScheduleOverdueBeanDto(OrderScheduleBean bean) {
        OrderScheduleOverdueDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderScheduleOverdueDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setPayWay(bean.getPayWay());
        }

        return beanDto;
    }

    public static OrderDealerDeliveryDto toOrderDealerDeliveryDto(OrderDealerDeliveryBean bean) {
        OrderDealerDeliveryDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderDealerDeliveryDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static <T extends OrderStatusFlowDto> List<T> toOrderStatusFlowDto(List<OrderStatusFlowBean> beanList,
                                                                              Class<T> clz) throws InstantiationException, IllegalAccessException {
        List<T> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderStatusFlowBean bean : beanList) {
                beanDtoList.add(toOrderStatusFlowDto(bean, clz));
            }
        }

        return beanDtoList;
    }

    public static <T extends OrderStatusFlowDto> T toOrderStatusFlowDto(OrderStatusFlowBean bean, Class<T> clz)
            throws InstantiationException, IllegalAccessException {
        T beanDto = null;
        if (bean != null) {
            beanDto = clz.newInstance();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setOrderModifiedType(bean.getOrderModifiedType());
            beanDto.setOrderStatus(bean.getOrderStatus());
        }

        return beanDto;
    }

    public static List<OrderScheduleRelationDto> toOrderScheduleRelationDto(List<OrderScheduleBean> beanList) {
        List<OrderScheduleRelationDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderScheduleBean bean : beanList) {
                beanDtoList.add(toOrderScheduleRelationDto(bean));
            }
        }

        return beanDtoList;
    }

    private static OrderScheduleRelationDto toOrderScheduleRelationDto(OrderScheduleBean bean) {
        OrderScheduleRelationDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderScheduleRelationDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<OrderReturnDto> toOrderReturnDto(List<OrderReturnBean> beanList) {
        List<OrderReturnDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderReturnBean bean : beanList) {
                beanDtoList.add(toOrderReturnDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderReturnDto toOrderReturnDto(OrderReturnBean bean) {
        OrderReturnDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderReturnDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<OrderMileageDto> toOrderMileageDto(List<OrderMileageBean> beanList) {
        List<OrderMileageDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderMileageBean bean : beanList) {
                beanDtoList.add(toOrderMileageDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderMileageDto toOrderMileageDto(OrderMileageBean bean) {
        OrderMileageDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderMileageDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static OrderSubscribeSettlementDto toOrderSubscribeSettlementDto(
            OrderSubscribeSettlementBean bean) {
        OrderSubscribeSettlementDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderSubscribeSettlementDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static OrderScheduleBean toOrderScheduleBean(OrderScheduleRepaymentModifyDto modifyDto) {
        OrderScheduleBean bean = null;
        if (modifyDto != null) {
            bean = new OrderScheduleBean();
            BeanUtils.copyProperties(modifyDto, bean);
            // 支付方式
            bean.setPayWay(modifyDto.getPayWay() == null ? null : modifyDto.getPayWay().getValue());
        }

        return bean;
    }

    public static OrderScheduleBean toOrderScheduleBean(OrderSchedulePayableDateModifyDto modifyDto) {
        OrderScheduleBean bean = null;
        if (modifyDto != null) {
            bean = new OrderScheduleBean();
            BeanUtils.copyProperties(modifyDto, bean);
        }

        return bean;
    }

    public static List<OrderDeliveryDto> toOrderDeliveryDto(List<OrderDeliveryBean> beanList) {
        List<OrderDeliveryDto> beanDtoList = null;
        if (beanList != null && beanList.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (OrderDeliveryBean bean : beanList) {
                beanDtoList.add(toOrderDeliveryDto(bean));
            }
        }

        return beanDtoList;
    }

    public static OrderDeliveryDto toOrderDeliveryDto(OrderDeliveryBean bean) {
        OrderDeliveryDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderDeliveryDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static OrderBean toOrderBean(OrderCreateDto createDto) {
        OrderBean bean = null;
        if (createDto != null) {
            bean = new OrderBean();
            BeanUtils.copyProperties(createDto, bean);
            bean.setType(createDto.getType().getValue());
            bean.setIsDelete(false);
        }
        return bean;
    }

    public static OrderExclusivelBean toOrderExclusivelBean(OrderExclusivelCreateDto createDto) {
        OrderExclusivelBean bean = null;
        if (createDto != null) {
            bean = new OrderExclusivelBean();
            BeanUtils.copyProperties(createDto, bean);
            bean.setIsDelete(false);
            if (OrderExclusivelTypeEnum.TYPE_ONE.equals(createDto.getType())) {
                bean.setOrderStatus(OrderExclusivelStatusEnum.TRADE_UNPAID.getValue());
            } else if (OrderExclusivelTypeEnum.TYPE_TWO.equals(createDto.getType())) {
                bean.setOrderStatus(OrderExclusivelStatusEnum.TRADE_CREDIT_UNAUDIT.getValue());
            }
            bean.setType(createDto.getType().getValue());
            bean.setSource(createDto.getSource().getValue());
            bean.setPaymentMethod(createDto.getPaymentMethod().getValue());
        }
        return bean;
    }

    public static OrderExclusivelBean toOrderExclusivelBean(OrderPayModifyDto modifyDto) {
        OrderExclusivelBean bean = new OrderExclusivelBean();
        BeanUtils.copyProperties(modifyDto, bean);
        // 支付类型
        bean.setPayWay(modifyDto.getPayWay().getValue());
        // 订单状态
        OrderExclusivelStatusEnum orderStatus = (OrderExclusivelStatusEnum) modifyDto.getOrderStatus();
        bean.setOrderStatus(orderStatus.getValue());
        return bean;
    }

    public static OrderSubscribeBean toOrderSubscribeBean(OrderSubscribeCreateDto createDto) {
        OrderSubscribeBean bean = null;
        if (createDto != null) {
            bean = new OrderSubscribeBean();
            BeanUtils.copyProperties(createDto, bean);
            bean.setIsDelete(false);
            bean.setOrderStatus(OrderSubscribeStatusEnum.TRADE_UNPAID.getValue());
            bean.setSource(createDto.getSource().getValue());
            bean.setPaymentMethod(createDto.getPaymentMethod().getValue());
        }
        return bean;
    }

    public static OrderSubscribeBean toOrderSubscribeBean(OrderPayModifyDto modifyDto) {
        OrderSubscribeBean bean = new OrderSubscribeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        // 支付类型
        bean.setPayWay(modifyDto.getPayWay().getValue());
        // 订单状态
        OrderSubscribeStatusEnum orderStatus = (OrderSubscribeStatusEnum) modifyDto.getOrderStatus();
        bean.setOrderStatus(orderStatus.getValue());
        return bean;
    }

    public static OrderMileageBean toOrderMileageBean(OrderMileageCreateDto createDto) {
        OrderMileageBean bean = null;
        if (createDto != null) {
            bean = new OrderMileageBean();
            BeanUtils.copyProperties(createDto, bean);
            bean.setStatus(OrderMileagePayStatusEnum.WAIT.getValue());
            bean.setPurchaseTime(LocalDateTime.now());
        }
        return bean;
    }

    public static OrderDeliveryBean toOrderDeliveryBean(OrderDeliveryCreateDto createDto) {
        OrderDeliveryBean bean = null;
        if (createDto != null) {
            bean = new OrderDeliveryBean();
            BeanUtils.copyProperties(createDto, bean);
        }

        return bean;
    }

    public static OrderReturnBean toOrderReturnBean(OrderReturnCreateDto createDto) {
        OrderReturnBean bean = null;
        if (createDto != null) {
            bean = new OrderReturnBean();
            BeanUtils.copyProperties(createDto, bean);
        }

        return bean;
    }

    public static OrderMileageBean toOrderMileageBean(OrderPayModifyDto modifyDto) {
        OrderMileageBean bean = null;
        if (modifyDto != null) {
            bean = new OrderMileageBean();
            bean.setOrderCode(modifyDto.getOrderCode());
            bean.setStatus(OrderMileagePayStatusEnum.PREPAID.getValue());
            bean.setPayWay(modifyDto.getPayWay().getValue());
            bean.setPayTime(modifyDto.getPayTime());
        }
        return bean;
    }

    public static OrderScheduleBean toOrderScheduleBean(OrderPayModifyDto modifyDto) {
        OrderScheduleBean bean = null;
        if (modifyDto != null) {
            bean = new OrderScheduleBean();
            bean.setId(modifyDto.getScheduleId());
            bean.setOrderCode(modifyDto.getOrderCode());
            bean.setStatus(OrderScheduleStatusEnum.ALREADY.getValue());
            bean.setPayWay(modifyDto.getPayWay().getValue());
            bean.setPaySuccessTime(modifyDto.getPayTime());
            bean.setRepayTerminal(modifyDto.getRepayTerminal());
        }
        return bean;
    }

    public static OrderSubscribeSettlementBean toOrderSubscribeSettlementBean(OrderPayModifyDto modifyDto) {
        OrderSubscribeSettlementBean bean = null;
        if (modifyDto != null) {
            bean = new OrderSubscribeSettlementBean();
            bean.setOrderCode(modifyDto.getOrderCode());
            bean.setStatus(OrderSubscribeSettlementPayStatusEnum.PREPAID.getValue());
            bean.setPayWay(modifyDto.getPayWay().getValue());
            bean.setPayTime(modifyDto.getPayTime());
        }
        return bean;
    }

    public static OrderAuditBean toOrderAuditBean(OrderAuditCreateDto createDto) {
        OrderAuditBean bean = null;
        if (createDto != null) {
            bean = new OrderAuditBean();
            BeanUtils.copyProperties(createDto, bean);
            bean.setType(createDto.getType().getValue());
            bean.setResult(createDto.getResult().getValue());
            bean.setAuditTime(LocalDateTime.now());
        }
        return bean;
    }

    public static OrderAuditDto toOrderAuditDto(OrderAuditBean bean) {
        OrderAuditDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderAuditDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }

    public static OrderExclusivelBean toOrderExclusivelBean(OrderDeliveryModifyDto modifyDto) {
        OrderExclusivelBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderExclusivelBean();
        BeanUtils.copyProperties(modifyDto, bean);
        // 订单状态-用车中
        bean.setOrderStatus(OrderExclusivelStatusEnum.TRADE_USE.getValue());
        return bean;
    }

    public static OrderSubscribeBean toOrderSubscribeBean(OrderDeliveryModifyDto modifyDto) {
        OrderSubscribeBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderSubscribeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        // 订单状态-用车中
        bean.setOrderStatus(OrderSubscribeStatusEnum.TRADE_USE.getValue());
        return bean;
    }

    public static OrderSubscribeBean toOrderSubscribeBean(OrderFinishModifyDto modifyDto) {
        OrderSubscribeBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderSubscribeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        OrderSubscribeStatusEnum orderStatus = (OrderSubscribeStatusEnum) modifyDto.getOrderStatus();
        bean.setOrderStatus(orderStatus.getValue());
        return bean;
    }

    public static OrderSubscribeBean toOrderSubscribeBean(OrderUseModifyDto modifyDto) {
        OrderSubscribeBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderSubscribeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        bean.setOrderStatus(OrderSubscribeStatusEnum.TRADE_USE.getValue());
        return bean;
    }

    public static OrderSubscribeSettlementBean toOrderSubscribeSettlementBean(
            OrderSubscribeSettlementCreateDto createDto) {
        OrderSubscribeSettlementBean bean = null;
        if (createDto == null) {
            return bean;
        }
        bean = new OrderSubscribeSettlementBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setStatus(createDto.getStatus().getValue());

        return bean;
    }

    public static OrderSubscribeSettlementBean toOrderSubscribeSettlementBean(
            OrderSubscribeSettlementModifyDto modifyDto) {
        OrderSubscribeSettlementBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderSubscribeSettlementBean();
        BeanUtils.copyProperties(modifyDto, bean);
        bean.setStatus(modifyDto.getStatus() == null ? null : modifyDto.getStatus().getValue());
        bean.setPayWay(modifyDto.getPayWay() == null ? null : modifyDto.getPayWay().getValue());

        return bean;
    }

    public static OrderSubscribeBean toOrderSubscribeBean(OrderReturnCarModifyDto modifyDto) {
        OrderSubscribeBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderSubscribeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        bean.setOrderStatus(OrderSubscribeStatusEnum.RETURN_UNINSPECTED.getValue());
        return bean;
    }

    public static OrderRenegeBean toOrderRenegeBean(OrderRenegeCreateDto createDto) {
        OrderRenegeBean bean = null;
        if (createDto == null) {
            return bean;
        }
        bean = new OrderRenegeBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setBeforeOrderStatus(createDto.getBeforeOrderStatus().getValue());
        bean.setRenegeStatus(createDto.getRenegeStatus().getValue());
        bean.setCostType(createDto.getCostType() == null ? null : createDto.getCostType().getValue());
        bean.setRenegeType(createDto.getRenegeType() == null ? null : createDto.getRenegeType().getValue());
        return bean;
    }

    public static List<OrderRenegeDto> toOrderRenegeDto(List<OrderRenegeBean> beanList) {
        List<OrderRenegeDto> beanDtoList = null;
        if (beanList != null && !beanList.isEmpty()) {
            beanDtoList = new ArrayList<>();
            for (OrderRenegeBean bean : beanList) {
                beanDtoList.add(toOrderRenegeDto(bean));
            }
        }
        return beanDtoList;
    }

    public static OrderRenegeDto toOrderRenegeDto(OrderRenegeBean bean) {
        OrderRenegeDto beanDto = null;
        if (bean != null) {
            beanDto = new OrderRenegeDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static OrderRenegeBean toOrderRenegeBean(OrderRenegeCostModifyDto modifyDto) {
        OrderRenegeBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderRenegeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        bean.setCostType(modifyDto.getCostType().getValue());
        bean.setRenegeStatus(OrderRenegeStatusEnum.RENEGE.getValue());
        return bean;
    }

    public static OrderRenegeBean toOrderRenegeBean(OrderRenegePayeeModifyDto modifyDto) {
        OrderRenegeBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new OrderRenegeBean();
        BeanUtils.copyProperties(modifyDto, bean);
        bean.setRenegeStatus(OrderRenegeStatusEnum.RENEGE.getValue());
        return bean;
    }

    public static GoodsSalesStatisticsBizDto toGoodsSalesStatisticsBizDto(OrderExclusivelBean bean) {
        if (bean == null) {
            return null;
        }
        GoodsSalesStatisticsBizDto bizDto = new GoodsSalesStatisticsBizDto();
        bizDto.setGoodsId(bean.getGoodsId());
        // 用车时长-付款方式-是否回购
        bizDto.setGoodsName(bean.getTransportTime() + "月-" +
                (OrderPaymentMethodEnum.INSTALLMENT.getValue() == bean.getPaymentMethod() ? "月付-" : "全款-") +
                (bean.getIsBuyback() ? "回购" : "不回购"));
        bizDto.setVehicleId(bean.getVehicleId());
        bizDto.setSales(1);

        return bizDto;
    }

    public static GoodsSalesStatisticsBizDto toGoodsSalesStatisticsBizDto(OrderSubscribeBean bean) {
        if (bean == null) {
            return null;
        }
        GoodsSalesStatisticsBizDto bizDto = new GoodsSalesStatisticsBizDto();
        bizDto.setGoodsId(bean.getGoodsId());
        bizDto.setPackageMileageId(bean.getPackageMileageId());
        // 用车时长-基础里程-订购里程
        bizDto.setGoodsName(bean.getTransportTime() + "月-" +
                bean.getBaseMileage() + "km-" + bean.getPackageMileage() + "km");
        bizDto.setVehicleId(bean.getVehicleId());
        bizDto.setSales(1);

        return bizDto;
    }


    public static List<OrderEnterpriseDto> toOrderEnterpriseDto(List<EnterpriseBean> beanList) {
        if (beanList == null || beanList.isEmpty()) {
            return null;
        }
        List<OrderEnterpriseDto> dtoList = new ArrayList<>();
        beanList.forEach(bean -> {
            dtoList.add(toEnterpriseDto(bean));
        });

        return dtoList;
    }

    public static OrderEnterpriseDto toEnterpriseDto(EnterpriseBean bean) {
        OrderEnterpriseDto dto = null;
        if (bean == null) {
            return dto;
        }
        dto = new OrderEnterpriseDto();
        BeanUtils.copyProperties(bean, dto);
        dto.setStateStr(EnterpriseStateEnum.getName(dto.getState()));
        return dto;
    }

    public static List<EnterpriseCarDto> toEnterpriseCarDto(List<EnterpriseCarBean> beanList) {
        List<EnterpriseCarDto> dtoList = null;
        if (beanList != null) {
            dtoList = new ArrayList<>();
            for (EnterpriseCarBean bean : beanList) {
                dtoList.add(toEnterpriseCarDto(bean));
            }
        }
        return dtoList;
    }

    public static EnterpriseCarDto toEnterpriseCarDto(EnterpriseCarBean bean) {
        EnterpriseCarDto dto = null;
        if (bean == null) {
            return dto;
        }

        dto = new EnterpriseCarDto();
        BeanUtils.copyProperties(bean, dto);
        return dto;
    }

    public static List<EnterpriseCarBean> toEnterpriseCarBean(List<EnterpriseCarCreateDto> createDtoList) {
        List<EnterpriseCarBean> beanList = null;
        if (createDtoList != null) {
            beanList = new ArrayList<>();
            for (EnterpriseCarCreateDto createDto : createDtoList) {
                beanList.add(toEnterpriseCarBean(createDto));
            }
        }
        return beanList;
    }

    public static EnterpriseCarBean toEnterpriseCarBean(EnterpriseCarCreateDto createDto) {
        EnterpriseCarBean bean = null;
        if (createDto == null) {
            return bean;
        }
        bean = new EnterpriseCarBean();
        BeanUtils.copyProperties(createDto, bean);
        // 待支付
        bean.setState(EnterpriseCarStateEnum.UNPAID.getValue());
        return bean;
    }

    public static EnterpriseCarBean toEnterpriseCarBean(EnterpriseCarModifyDto modifyDto, EnterpriseCarStateEnum state) {
        EnterpriseCarBean bean = null;
        if (modifyDto == null) {
            return bean;
        }
        bean = new EnterpriseCarBean();
        BeanUtils.copyProperties(modifyDto, bean);
        bean.setState(state.getValue());
        return bean;
    }

    public static EnterpriseCarTransferDto toEnterpriseCarTransferDto(EnterpriseCarTransferBean bean) {
        EnterpriseCarTransferDto dto = null;
        if (bean == null) {
            return dto;
        }
        dto = new EnterpriseCarTransferDto();
        BeanUtils.copyProperties(bean, dto);
        return dto;
    }

    public static EnterpriseBean toEnterpriseBean(OrderEnterpriseCreateDto createDto) {
        EnterpriseBean bean = null;
        if (createDto == null) {
            return bean;
        }
        bean = new EnterpriseBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setState(EnterpriseStateEnum.UNPAID.getValue());
        return bean;
    }

    public static List<EnterpriseScheduleDto> toEnterpriseScheduleDtoList(List<EnterpriseScheduleBean> beanList) {
        List<EnterpriseScheduleDto> dtoList = new ArrayList<>();
        if (beanList != null && beanList.size() > 0) {
            for (EnterpriseScheduleBean bean : beanList) {
                dtoList.add(toEnterpriseScheduleDto(bean));
            }
        }
        return dtoList;
    }

    public static EnterpriseScheduleDto toEnterpriseScheduleDto(EnterpriseScheduleBean bean) {
        EnterpriseScheduleDto beanDto = null;
        if (bean != null) {
            beanDto = new EnterpriseScheduleDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setScheduleId(bean.getId());
            Integer state = bean.getState();
            if (state != null) {
                beanDto.setStateStr(EnterpriseScheduleStateEnum.getName(state));
            }
        }
        return beanDto;
    }

    public static EnterpriseScheduleBean toEnterpriseScheduleBean(EnterpriseScheduleCreateDto createDto) {
        if (createDto == null) {
            return null;
        }
        EnterpriseScheduleBean bean = new EnterpriseScheduleBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setState(createDto.getState() == null ? EnterpriseScheduleStateEnum.NO.getValue() : createDto.getState().getValue());
        return bean;
    }


    public static List<EnterpriseCarHandoverDto> toEnterpriseCarHandoverDto(List<EnterpriseCarHandoverBean> beanList) {
        if (beanList == null || beanList.isEmpty()) {
            return null;
        }
        List<EnterpriseCarHandoverDto> dtoList = new ArrayList<>();
        beanList.forEach(bean -> {
            dtoList.add(toEnterpriseCarHandoverDto(bean));
        });

        return dtoList;
    }

    public static EnterpriseCarHandoverDto toEnterpriseCarHandoverDto(EnterpriseCarHandoverBean bean) {
        if (bean == null) {
            return null;
        }
        EnterpriseCarHandoverDto dto = new EnterpriseCarHandoverDto();
        BeanUtils.copyProperties(bean, dto);
        return dto;
    }

    public static List<EnterpriseScheduleCarBean> toEnterpriseScheduleCarBean(List<EnterpriseScheduleCarCreateDto> createDtos) {
        if (createDtos == null || createDtos.isEmpty()) {
            return null;
        }
        List<EnterpriseScheduleCarBean> beanList = new ArrayList<>();
        createDtos.forEach(dto -> {
            beanList.add(toEnterpriseScheduleCarBean(dto));
        });

        return beanList;
    }

    public static EnterpriseScheduleCarBean toEnterpriseScheduleCarBean(EnterpriseScheduleCarCreateDto dto) {
        if (dto == null) {
            return null;
        }
        EnterpriseScheduleCarBean bean = new EnterpriseScheduleCarBean();
        BeanUtils.copyProperties(dto, bean);
        bean.setState(dto.getState() == null ? EnterpriseScheduleStateEnum.NO.getValue() : dto.getState().getValue());
        return bean;
    }


    public static EnterpriseCarHandoverBean toEnterpriseCarHandoverBean(EnterpriseCarHandoverCreateDto dto) {
        EnterpriseCarHandoverBean bean = null;
        if (dto != null) {
            bean = new EnterpriseCarHandoverBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }


    public static EnterpriseCarHandoverCreateDto toEnterpriseCarHandoverCreateDto(OrderEnterpriseReturnCreateBizDto createBizDto,
                                                                                  EnterpriseCarDto enterpriseCar) {
        EnterpriseCarHandoverCreateDto createDto = null;
        if (createBizDto != null) {
            createDto = new EnterpriseCarHandoverCreateDto();
            BeanUtils.copyProperties(createBizDto, createDto);
            createDto.setHandoverTime(LocalDateTime.now());
            if (enterpriseCar != null) {
                createDto.setLicencePlate(enterpriseCar.getLicencePlate());
                createDto.setColorId(enterpriseCar.getColorId());
                createDto.setModelId(enterpriseCar.getModelId());
                createDto.setStartMileage(enterpriseCar.getStartMileage());
            }
        }
        return createDto;
    }

    public static EnterpriseCarModifyDto toEnterpriseCarModifyDto(OrderEnterpriseReturnCreateBizDto createBizDto,
                                                                  EnterpriseCarDto enterpriseCar) {
        EnterpriseCarModifyDto modifyDto = null;
        if (createBizDto != null) {
            modifyDto = new EnterpriseCarModifyDto();
            BeanUtils.copyProperties(createBizDto, modifyDto);
            modifyDto.setEndMileage(createBizDto.getReturnMileage());
        }
        return modifyDto;
    }

    public static EnterpriseCarHandoverCreateDto toEnterpriseCarHandoverCreateDto(OrderEnterpriseDeliveryCreateBizDto bean, EnterpriseCarDto enterpriseCar) {
        EnterpriseCarHandoverCreateDto dto = null;
        if (bean != null) {
            dto = new EnterpriseCarHandoverCreateDto();
            BeanUtils.copyProperties(bean, dto);
            dto.setHandoverTime(LocalDateTime.now());
            if (enterpriseCar != null) {
                dto.setLicencePlate(enterpriseCar.getLicencePlate());
                dto.setColorId(enterpriseCar.getColorId());
                dto.setModelId(enterpriseCar.getModelId());
                dto.setStartMileage(enterpriseCar.getStartMileage());
            }
        }
        return dto;
    }

    public static EnterpriseCarModifyDto toEnterpriseCarModifyDto(OrderEnterpriseDeliveryCreateBizDto bean, EnterpriseCarDto enterpriseCar) {
        EnterpriseCarModifyDto dto = null;
        if (bean != null) {
            dto = new EnterpriseCarModifyDto();
            BeanUtils.copyProperties(bean, dto);
        }
        return dto;
    }

    public static List<EnterpriseCarDto> toOrderEnterpriseCarDto(List<EnterpriseCarBean> page) {
        List<EnterpriseCarDto> beanDtoList = null;
        if (page != null && page.size() > 0) {
            beanDtoList = new ArrayList<>();
            for (EnterpriseCarBean bean : page) {
                beanDtoList.add(toEnterpriseCarDto(bean));
            }
        }

        return beanDtoList;

    }


    public static List<EnterpriseStateFlowDto> toEnterpriseStateFlowDto(List<EnterpriseStateFlowBean> beanList) {
        if (beanList == null || beanList.isEmpty()) {
            return null;
        }
        List<EnterpriseStateFlowDto> dtoList = new ArrayList<>();
        beanList.forEach(bean -> {
            dtoList.add(toEnterpriseStateFlowDto(bean));
        });

        return dtoList;
    }

    public static EnterpriseStateFlowDto toEnterpriseStateFlowDto(EnterpriseStateFlowBean bean) {
        if (bean == null) {
            return null;
        }
        EnterpriseStateFlowDto dto = new EnterpriseStateFlowDto();
        BeanUtils.copyProperties(bean, dto);
        return dto;
    }

    public static LawsuitBean toLawsuitBean(LawsuitCreateDto createDto) {
        if (createDto == null) {
            return null;
        }
        LawsuitBean bean = new LawsuitBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setLawsuitState(createDto.getLawsuitState().getValue());
        return bean;
    }

    public static LawsuitDto toLawsuitDto(LawsuitBean bean) {
        if (bean == null) {
            return null;
        }

        LawsuitDto dto = new LawsuitDto();
        BeanUtils.copyProperties(bean, dto);
        dto.setLawsuitStateStr(LawsuitStateEnum.getName(dto.getLawsuitState()));
        return dto;
    }

    public static RecycleCarsBean toRecycleCarsBean(RecycleCarsCreateDto createDto) {
        if (createDto == null) {
            return null;
        }

        RecycleCarsBean bean = new RecycleCarsBean();
        BeanUtils.copyProperties(createDto, bean);
        bean.setRecycleState(createDto.getRecycleState().getValue());
        return bean;
    }

    public static List<RecycleCarsDto> toRecycleCarsDto(List<RecycleCarsBean> beans) {
        if (beans == null || beans.isEmpty()) {
            return null;
        }
        List<RecycleCarsDto> dtos = new ArrayList<>(beans.size());
        for (RecycleCarsBean bean : beans) {
            dtos.add(Convert.toRecycleCarsDto(bean));
        }

        return dtos;
    }

    public static RecycleCarsDto toRecycleCarsDto(RecycleCarsBean bean) {
        if (bean == null) {
            return null;
        }
        RecycleCarsDto dto = new RecycleCarsDto();
        BeanUtils.copyProperties(bean, dto);
        dto.setRecycleStateStr(RecycleStateEnum.getName(dto.getRecycleState()));
        return dto;
    }

    public static RecycleCarsBean toRecycleCarsBean(OrderRecycleCarsModifyDto modifyDto) {
        if (modifyDto == null) {
            return null;
        }
        RecycleCarsBean bean = new RecycleCarsBean();
        BeanUtils.copyProperties(modifyDto, bean);

        return bean;
    }

    public static OrderReturnBean toOrderReturnBean(OrderRecycleCarsModifyDto modifyDto) {
        if (modifyDto == null) {
            return null;
        }
        OrderReturnBean bean = new OrderReturnBean();
        BeanUtils.copyProperties(modifyDto, bean);

        return bean;
    }
}
